package com.example.sample.logic.fsm;

import android.os.Handler;

import com.example.sample.SampleApp;
import com.example.sample.logic.fsm.base.FSMEvt;
import com.example.sample.logic.fsm.base.FSMState;

import net.liteheaven.xblib.common.ui.ToastUtil;

/**
 * 禁言状态
 */
public class FSMStateNoSay extends FSMState {

    @Override
    protected int getStateValue() {
        return TestFSMConst.STATE_NoSay;
    }

    @Override
    protected void onActive() {
        ToastUtil.show(SampleApp.getApp(), "你被禁言了");
        new Handler().postDelayed(new Runnable() {
            @Override
            public void run() {
                ToastUtil.show(SampleApp.getApp(), "禁言时间够长了，即将解禁");
                new Handler().postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        manager.fireEvent(new FSMEvtRestoreToNormal());
                    }
                }, 2000);
            }
        },10000);
    }

    @Override
    protected void handleEvt(FSMEvt evt) {
        switch (evt.getEvtValue()){
            case TestFSMConst.EvtRestoreToNormal:
                changeState(TestFSMConst.STATE_Normal);
                break;
            case TestFSMConst.EVT_MSG:
                ToastUtil.show(SampleApp.getApp(), "被禁言了无法发送");
                break;

        }
    }
}
